package com.api.phm.domain.query;

import com.api.common.config.ApiConfig;
import com.api.phm.util.EncryptionUtil;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

@Data
public class RealTimeQuery {
    private Long plcId;
    private String plcIp;
    private String plcUser;
    private String plcPwd;
    private String plcCode;
    private String elementCode;
    private int elementNum;

    public void decryptPlcPwd() {
        try {
            String pwd = this.plcPwd;
            if (StringUtils.isNotBlank(pwd)) {
                pwd = EncryptionUtil.decryptWithAES(
                        EncryptionUtil.decodeBase64(pwd), ApiConfig.getCsId()
                );
            }
            this.plcPwd = pwd;
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
